package com.jinyu.jyly.ui.mine.passageway;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.recyclerview.widget.RecyclerView;

import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.jinyu.jyly.R;
import com.jinyu.jyly.adapter.ExtensionAdapter;
import com.jinyu.jyly.base.BaseFragment;
import com.jinyu.jyly.bean.AllInfoBean;
import com.jinyu.jyly.bean.GetPriceInfo;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import butterknife.BindView;
import butterknife.OnClick;


/**
 *
 * @author 62485
 */
public class PassageNewerTabFragment extends BaseFragment<PassageNewerPresenter> implements PassageNewsContract.View {


    @BindView(R.id.btn_sub)
    Button btnSub;
    @BindView(R.id.rcv_price)
    RecyclerView rcv_price;


    private PassageNewerPresenter presenter;
    private int type;
    private ExtensionAdapter extensionAdapter;

    public static Set<Integer> positionSet = new HashSet<>();
    public Set<Integer> checkTYpeNameSet = new HashSet<>();
    private boolean selectMode = false; //选择模式 多选或者单选  true  多选
    private List<GetPriceInfo> mList;

    public static PassageNewerTabFragment newInstance(int type) {
        PassageNewerTabFragment newFragment = new PassageNewerTabFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        newFragment.setArguments(bundle);
        return newFragment;
    }


    @Override
    protected View initView(ViewGroup container) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.fragment_tab_passage_newer, container, false); //fragment_tab_passage_way
        return view;
    }

    @Override
    protected void loadData() {
        type = getArguments().getInt("type");

    }



    @Override
    public PassageNewerPresenter getPresenter() {
        if (presenter == null) {
            presenter = new PassageNewerPresenter(getActivity(), this);
        }
        return presenter;
    }



    @Override
    public void onFailer(Throwable throwable) {

    }




    /**
     * 新人预排接口
     * @param infoBean
     */
    @Override
    public void onAddNewGreen(AllInfoBean infoBean) {
        switch (infoBean.getStatus()){
            case 200:
                String data = infoBean.getData();
                showToast("提交成功");
                getActivity().finish();
                break;
            case 422:
                showToast(infoBean.getMsg());
                break;
            default:break;
        }
    }

    @OnClick(R.id.btn_sub)
    public void onViewClicked() {
        setSignOutApp();
    }


    //抢拍
    private int mCurrentDialogStyle = com.qmuiteam.qmui.R.style.QMUI_Dialog;
    private void setSignOutApp() {
        new QMUIDialog.MessageDialogBuilder(getActivity())
                .setTitle("竞拍提示")
                .setMessage("您确认花费20宝石交付1天商城竞拍保证金吗？")
                .addAction("取消", new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                    }
                })
                .addAction(0, "确定", QMUIDialogAction.ACTION_PROP_NEGATIVE, new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                        mPresenter.setAddNewGreen();
                    }
                })
                .create(mCurrentDialogStyle).show();
    }


}
